package com.threeti.mecool.core.infrastructure.persistence.project;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.threeti.mecool.core.domain.model.project.ProjectSalesPromoter;

public interface ProjectSalesPromoterRepository extends JpaRepository<ProjectSalesPromoter, Long>,JpaSpecificationExecutor<ProjectSalesPromoter> {  
  @Modifying
  @Transactional
  @Query("delete from ProjectSalesPromoter pe where pe.project.id = ?1")  
  void deleteByProjectId(Long projectId);
  
  Page<ProjectSalesPromoter> findByProjectId(Long projectId, Pageable pageable);
  
  List<ProjectSalesPromoter> findByProjectId(Long projectId);
  
  ProjectSalesPromoter findByProjectCodeAndSalesPromoterCode(String projectCode, String salesPromoterCode);
  
  /** 取得(分配给)特定项目门店的促销员集合*/
  List<ProjectSalesPromoter> findByAssignedStoresId(Long projStoreId);
  
  ProjectSalesPromoter findBySalesPromoterCodeAndProjectId(String salesCode, Long projectId);
}
